<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">类别名称</label>
        <div class="layui-input-block">
            <select name="table_name" id="table_name" lay-verify="required" lay-search="">
                <option value="">直接选择或搜索选择</option>
                {foreach $data as $vo}
                <option value="{$vo.table_name}">{$vo.dic_name}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="layui-input-block">
            <button type="button" class="layui-btn layui-btn-warm btn-embossed"
                    style="background-color: #f39c12 !important; border-radius: 5px;" onclick="check_select()">导入
            </button>
            <button type="button" id='import' class="layui-btn layui-btn-warm btn-embossed"
                    style="background-color: #f39c12 !important; border-radius: 5px; display:none;">导入
            </button>
        </div>
    </div>
</div>
<script src="/static/admin/video/jquery.js"></script>
<script src="/static/admin/layui/layui.js"></script>
<script>
    var uploadExcel = "{:url('dictionaries/export')}";
    layui.config({
        base: '/static/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
        treeTable: '../admin/lib/extend/authtree'
    }).use(['index', 'form', 'upload', 'laydate'], function () {
        var $ = layui.$, form = layui.form, laydate = layui.laydate, upload = layui.upload;
        upload.render({
            elem: "#import" //绑定元素
            , url: uploadExcel //上传接口
            , multiple: false
            , accept: 'file'
            , acceptMime: 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
            , exts: 'xls|xlsx'
            , auto: true
            , before: function (obj) { //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                this.data = {
                    "table": $('#table_name').val()
                };
                layer.load(1); //上传loading
            }
            , done: function (res) {
                if (res.code == 200) {
                    layer.msg(res.msg, {icon: 1,time: 2000}, function () {
                        layer.closeAll();
                        window.parent.location.reload();
                    });
                } else {
                    layer.closeAll('loading');
                    layer.msg(res.msg, {icon: 5});
                    return false;
                }
            }
            , error: function () {
                layer.closeAll('loading');
                //请求异常回调
            }
        });

    });

    function check_select() {
        if ($('#table_name').val() == "") {
            layer.msg("请选择表")
            return false;
        }else{
            //在此做你的检查
            $('#import').click(); //检查通过再选上传图片
        }

    }
</script>